#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include "./rdtsc.h"
#include "./mem.h"
#include "./cpu.h"
// #define DEBUG

//pid_t pid;
unsigned long long begin_tick, end_tick;
unsigned long long curr_CPU_freq;

int main(int argc, char *argv[])
{
  curr_CPU_freq = get_current_CPU_freq();  
  // start timer
  begin_tick = rdtsc();
  #ifdef DEBUG
  fprintf(stderr, "Begin tick is %llu\n", begin_tick);
  #endif
  
  gettimeofday();
  #ifdef DEBUG
  fprintf(stderr, "Current pid is %d\n", pid); 
  #endif 

  // end timer
  end_tick = rdtsc();
  #ifdef DEBUG
  fprintf(stderr, "End tick is %llu\n", end_tick);
  fprintf(stderr, "Total tick is %llu\n", (end_tick - begin_tick)); 
  #endif
  
  // print time
  double time_duration = (double)(end_tick - begin_tick) / (double)curr_CPU_freq;
  printf("%3.8f\n", time_duration);

}

